function handleImgUrl(img,domain,path="/uploads/") {
  let ret;
  if (!img) {
    ret = domain + "/api/goods/img/noimg.png";
  } else {
    ret = domain + path + img;
  }
  return ret;
}

// 驼峰转换下划线
function camelSnake(name) {
    return name.replace(/([A-Z])/g,"_$1").toLowerCase();
}

function camelSnakeJson(body) {
    return JSON.parse(camelSnake(JSON.stringify(body)))
}

module.exports = { handleImgUrl,camelSnake,camelSnakeJson }
